
const express = require('express');
const router = express.Router();

const db = require("../config/mydb.js");

router.get('/login', function (req, res, next) {
    let user = req.query.user
    let pwd = req.query.pwd
    let sql = "select * from sao_user where user='" + user + "' and password='" + pwd + "'"
    db.query(sql, function (err, rows) {
        // req.session.pp='11'
        if (!!rows[0]) {
            req.session.user=JSON.stringify(rows[0].id)
            res.send('登录成功！')
        } else {
            res.send('登录失败！')
        }
    })
})
router.get('/nowlogin', function (req, res, next) {
    res.send(req.session.user)
})

router.get('/', function (req, res, next) {
    res.send(req.session.user)
})
module.exports = router